<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {

    return view('index');
});
//验证码
Route::post('/sendsms', 'Auth\LoginController@sendsms');
//微信支付回调
Route::post('/notify_url', 'NotifyController@notify_url');
Route::any('/alipay/notify_url', 'NotifyController@alipay_notify_url');

Route::get('/good', 'GoodController@index');
Route::any('/good/list', 'GoodController@list')->name('good.list');
Route::any('/good/detail', 'GoodController@detail');
Route::get('/page', 'PageController@index');
Route::get('/news', 'NewsController@index');
Route::get('/newsDetail/{id}', 'NewsController@detail')->where(['id' => '[0-9]+']);
Auth::routes();
/**找回密码**/
Route::post('/password/checkCode', 'Auth\ForgotPasswordController@checkCode')->name('password.checkCode');
Route::post('/password/resetsPassword', 'Auth\ForgotPasswordController@resetsPassword')->name('password.resetsPassword');

Route::get('/home', 'HomeController@index')->name('home');
//需求

//用户
Route::group(['middleware' => ['auth', 'web' ]], function () {

    Route::post('/user/addCart', 'Auth\UserController@addCart')->name('addCart');
    Route::post('/user/getCal', 'Auth\UserController@getCal')->name('getCal');
    Route::post('/user/cartCommit', 'Auth\UserController@cartCommit')->name('cartCommit');
    Route::any('/user/cart', 'Auth\UserController@cart');
    Route::any('/user/toAddress', 'Auth\UserController@toAddress');
    Route::any('/user/toAddressDetail', 'Auth\UserController@toAddressDetail');
    Route::post('/user/createPay', 'Auth\UserController@createPay');
    Route::any('/user/toInfo', 'Auth\UserController@toInfo')->name('toInfo');
    Route::any('/user/toMyOrder', 'Auth\UserController@toMyOrder')->name('toMyOrder');

    Route::get('/user/toChoose', 'Auth\UserController@toChoose')->name('toChoose');
    Route::post('/user/toChoose', 'Auth\UserController@toChoose')->name('toChoosepost')->middleware('wechat.oauth');
    Route::any('/user/toAlterPass', 'Auth\UserController@toAlterPass')->name('toAlterPass');




	Route::get('/pay', ['as' => 'website.pay', 'uses' => 'PayController@index']);

});
Route::group(['middleware' => ['web', 'wechat.oauth']], function () {
    Route::get('/user', function () {
        $user = session('wechat.oauth_user'); // 拿到授权用户资料

        dd($user);
    });
});
